package org.example.linkedList;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * @Auther: wangbw
 * @Date:2020/11/11
 * @Description: org.example.linkedList
 * @version: 1.0
 */
@Getter
@Setter
@AllArgsConstructor
public class Node {
    String data;
    Node next;

    public static final Node createNode(int size){
        Node head = new Node("0", null);
        Node headCopy = head;
        for (int i = 1; i < size; i++) {
            head.setNext(new Node(i + "", null));
            head = head.getNext();
        }
        return headCopy;
    }

    public static final void print(Node headArg){
        Node head =headArg;
        while (head != null){
            System.out.print(head.data + "  ->");
            head = head.getNext();
        }
        System.out.println("  NULL");
    }

    public static final Node createNode(String ...args){
        if (args == null || args.length == 0)
            return null;
        Node head = new Node(args[0], null);
        Node headCopy = head;
        for (int i = 1; i < args.length; i++) {
            Node temp = new Node(args[i], null);
            headCopy.setNext(temp);
            headCopy = temp;
        }
        return head;
    }
}
